package com.tang.source;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.Arrays;

/**
 * 从集合中读取数据
 *
 * @author tang
 * @since 2023/5/31 14:59
 */
public class CollectionDemo {

    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        /*
         * fromCollection(Collection <OUT> data)
         * fromElements(OUT... data)
         */
        DataStreamSource<Integer> source = env//.fromElements(1, 2, 3)
                .fromCollection(Arrays.asList(1, 2, 3));

        source.print();

        env.execute();
        
    }

}
